package Model;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;


public class restaurantType {

	public static List <Integer> listOfRestaurantType1 (long rtid) throws Exception {
		URL url = new URL("http://happywaiman.dlinkddns.com/Reserve/Company/fetchNear.php?type=1&subType="+rtid);
		ReadFromURL reader = new ReadFromURL();
		String content = reader.getContentFromURL(url);
		JSONArray array = new JSONArray(content);
		List <Integer> l = new ArrayList();
		for (int i = 0; i < array.length(); i++) {
			String obj = (String) array.getString(i);
			l.add(Integer.parseInt(obj));
		}
		
		return l;
	}

	public static List <String> listOfRestaurantType () throws Exception {
		URL url = new URL("http://happywaiman.dlinkddns.com/Reserve/Company/CompanyType.php?type=1");
		ReadFromURL reader = new ReadFromURL();
		String content = reader.getContentFromURL(url);
		JSONArray array = new JSONArray(content);
		List <String> l = new ArrayList<String>();
		for (int i = 0; i < array.length(); i++) {
			JSONArray obj = (JSONArray) array.get(i);
			l.add((String) obj.get(1));
		}
		return l;
	}
	
}
